package com.alliky.core.utils;

import android.view.View;

import com.jakewharton.rxbinding2.view.RxView;

import java.util.concurrent.TimeUnit;

/**
 * @Author: wxianing
 * @CreateDate: 2022/8/28 13:09
 * @Description: java类作用描述
 */
public class RxClick {

    //点击间隔时间
    public static int INTERVAL_TIME = 2;

    public static void setOnClickListener(final View view, View.OnClickListener onClickListener) {
        setOnClickListener(view, INTERVAL_TIME, onClickListener);
    }

    public static void setOnClickListener(final View view, int time, View.OnClickListener onClickListener) {
        RxView.clicks(view)
                .throttleFirst(time, TimeUnit.SECONDS)
                .subscribe(o -> {
                    onClickListener.onClick(view);
                });
    }
}
